<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Home extends CI_Controller
{
    function __construct() {
        parent::__construct();
        $this->load->model('init_model', 'init');
        $this->load->library('session');
        
        $this->load->library('auth');
    }


    /**
     * Index Page for this controller.
     */
    public function index()
    {
        $this->auth->restrict();
        $data['nav'] = 'dashboard';
        $this->core_events->trigger('backend/home');
        $this->load->model('init_model', 'init');
        //$this->load->view('home_message');
        $this->init->display_template('home', $data, 'backend');
        
    }
    
    /**
	* Login Controller
	* Allow the admin to login
	*
	* @access	public
	*/
    function login()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'lang:kb_username', 'required');
	    $this->form_validation->set_rules('password', 'lang:kb_password', 'required');
	    $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
        
        $data='';
        if($this->form_validation->run() == false)
        {
           $this->load->view('backend/default/login', $data);
        } else {
            $login = array($this->input->post('username'), $this->input->post('password'));
            if($this->auth->process_login($login))
            {
                redirect('backend');
            }
            else
            {
                $data['error']=$this->lang->line('kb_login_invalid');
                $this->load->view('backend/default/login', $data);
            }
        }
    }
}
/* End of file home.php */
/* Location: ./application/controllers/backend/home.php */
